package edu.upf.grupE.Entities;

/*
 * This class was automatically generated with 
 * <a href="http://www.castor.org">Castor 1.1.2.1</a>, using an XML
 * Schema.
 * $Id$
 */

//---------------------------------/
//- Imported classes and packages -/
//---------------------------------/
import org.exolab.castor.xml.Marshaller;
import org.exolab.castor.xml.Unmarshaller;

/**
 * Class TextDescription.
 * 
 * @version $Revision$ $Date$
 */
public class TextDescription implements java.io.Serializable {


    //--------------------------/
    //- Class/Member Variables -/
    //--------------------------/
    /**
     * Field _tagList.
     */
    private java.util.List _tagList;
    /**
     * Field _userKeywordsList.
     */
    private java.util.List _userKeywordsList;
    /**
     * Field _description.
     */
    private java.lang.String _description;


    //----------------/
    //- Constructors -/
    //----------------/
    public TextDescription() {
        super();
        this._tagList = new java.util.ArrayList();
        this._userKeywordsList = new java.util.ArrayList();
    }


    //-----------/
    //- Methods -/
    //-----------/
    /**
     * 
     * 
     * @param vTag
     * @throws java.lang.IndexOutOfBoundsException if the index
     * given is outside the bounds of the collection
     */
    public void addTag(
            final Tag vTag)
            throws java.lang.IndexOutOfBoundsException {
        this._tagList.add(vTag);
    }

    /**
     * 
     * 
     * @param index
     * @param vTag
     * @throws java.lang.IndexOutOfBoundsException if the index
     * given is outside the bounds of the collection
     */
    public void addTag(
            final int index,
            final Tag vTag)
            throws java.lang.IndexOutOfBoundsException {
        this._tagList.add(index, vTag);
    }

    /**
     * 
     * 
     * @param vUserKeywords
     * @throws java.lang.IndexOutOfBoundsException if the index
     * given is outside the bounds of the collection
     */
    public void addUserKeywords(
            final java.lang.String vUserKeywords)
            throws java.lang.IndexOutOfBoundsException {
        this._userKeywordsList.add(vUserKeywords);
    }

    public void addUserKeyword(final java.lang.String vUserKeyword) {
        this._userKeywordsList.add(vUserKeyword);
    }

    /**
     * 
     * 
     * @param index
     * @param vUserKeywords
     * @throws java.lang.IndexOutOfBoundsException if the index
     * given is outside the bounds of the collection
     */
    public void addUserKeywords(
            final int index,
            final java.lang.String vUserKeywords)
            throws java.lang.IndexOutOfBoundsException {
        this._userKeywordsList.add(index, vUserKeywords);
    }

    /**
     * Method enumerateTag.
     * 
     * @return an Enumeration over all possible elements of this
     * collection
     */
    public java.util.Enumeration enumerateTag() {
        return java.util.Collections.enumeration(this._tagList);
    }

    /**
     * Method enumerateUserKeywords.
     * 
     * @return an Enumeration over all possible elements of this
     * collection
     */
    public java.util.Enumeration enumerateUserKeywords() {
        return java.util.Collections.enumeration(this._userKeywordsList);
    }

    /**
     * Returns the value of field 'description'.
     * 
     * @return the value of field 'Description'.
     */
    public java.lang.String getDescription() {
        return this._description;
    }

    /**
     * Method getTag.
     * 
     * @param index
     * @throws java.lang.IndexOutOfBoundsException if the index
     * given is outside the bounds of the collection
     * @return the value of the Tag at the given index
     */
    public Tag getTag(
            final int index)
            throws java.lang.IndexOutOfBoundsException {
        // check bounds for index
        if (index < 0 || index >= this._tagList.size()) {
            throw new IndexOutOfBoundsException("getTag: Index value '" + index + "' not in range [0.." + (this._tagList.size() - 1) + "]");
        }

        return (Tag) _tagList.get(index);
    }

    /**
     * Method getTag.Returns the contents of the collection in an
     * Array.  <p>Note:  Just in case the collection contents are
     * changing in another thread, we pass a 0-length Array of the
     * correct type into the API call.  This way we <i>know</i>
     * that the Array returned is of exactly the correct length.
     * 
     * @return this collection as an Array
     */
    public Tag[] getTag() {
        Tag[] array = new Tag[0];
        return (Tag[]) this._tagList.toArray(array);
    }

    /**
     * Method getTagCount.
     * 
     * @return the size of this collection
     */
    public int getTagCount() {
        return this._tagList.size();
    }

    /**
     * Method getUserKeywords.
     * 
     * @param index
     * @throws java.lang.IndexOutOfBoundsException if the index
     * given is outside the bounds of the collection
     * @return the value of the java.lang.String at the given index
     */
    public java.lang.String getUserKeywords(
            final int index)
            throws java.lang.IndexOutOfBoundsException {
        // check bounds for index
        if (index < 0 || index >= this._userKeywordsList.size()) {
            throw new IndexOutOfBoundsException("getUserKeywords: Index value '" + index + "' not in range [0.." + (this._userKeywordsList.size() - 1) + "]");
        }

        return (java.lang.String) _userKeywordsList.get(index);
    }

    /**
     * Method getUserKeywords.Returns the contents of the
     * collection in an Array.  <p>Note:  Just in case the
     * collection contents are changing in another thread, we pass
     * a 0-length Array of the correct type into the API call. 
     * This way we <i>know</i> that the Array returned is of
     * exactly the correct length.
     * 
     * @return this collection as an Array
     */
    public java.lang.String[] getUserKeywords() {
        java.lang.String[] array = new java.lang.String[0];
        return (java.lang.String[]) this._userKeywordsList.toArray(array);
    }

    /**
     * Method getUserKeywordsCount.
     * 
     * @return the size of this collection
     */
    public int getUserKeywordsCount() {
        return this._userKeywordsList.size();
    }

    /**
     * Method isValid.
     * 
     * @return true if this object is valid according to the schema
     */
    public boolean isValid() {
        try {
            validate();
        } catch (org.exolab.castor.xml.ValidationException vex) {
            return false;
        }
        return true;
    }

    /**
     * Method iterateTag.
     * 
     * @return an Iterator over all possible elements in this
     * collection
     */
    public java.util.Iterator iterateTag() {
        return this._tagList.iterator();
    }

    /**
     * Method iterateUserKeywords.
     * 
     * @return an Iterator over all possible elements in this
     * collection
     */
    public java.util.Iterator iterateUserKeywords() {
        return this._userKeywordsList.iterator();
    }

    /**
     * 
     * 
     * @param out
     * @throws org.exolab.castor.xml.MarshalException if object is
     * null or if any SAXException is thrown during marshaling
     * @throws org.exolab.castor.xml.ValidationException if this
     * object is an invalid instance according to the schema
     */
    public void marshal(
            final java.io.Writer out)
            throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
        Marshaller.marshal(this, out);
    }

    /**
     * 
     * 
     * @param handler
     * @throws java.io.IOException if an IOException occurs during
     * marshaling
     * @throws org.exolab.castor.xml.ValidationException if this
     * object is an invalid instance according to the schema
     * @throws org.exolab.castor.xml.MarshalException if object is
     * null or if any SAXException is thrown during marshaling
     */
    public void marshal(
            final org.xml.sax.ContentHandler handler)
            throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
        Marshaller.marshal(this, handler);
    }

    /**
     */
    public void removeAllTag() {
        this._tagList.clear();
    }

    /**
     */
    public void removeAllUserKeywords() {
        this._userKeywordsList.clear();
    }

    /**
     * Method removeTag.
     * 
     * @param vTag
     * @return true if the object was removed from the collection.
     */
    public boolean removeTag(
            final Tag vTag) {
        boolean removed = _tagList.remove(vTag);
        return removed;
    }

    /**
     * Method removeTagAt.
     * 
     * @param index
     * @return the element removed from the collection
     */
    public Tag removeTagAt(
            final int index) {
        java.lang.Object obj = this._tagList.remove(index);
        return (Tag) obj;
    }

    /**
     * Method removeUserKeywords.
     * 
     * @param vUserKeywords
     * @return true if the object was removed from the collection.
     */
    public boolean removeUserKeywords(
            final java.lang.String vUserKeywords) {
        boolean removed = _userKeywordsList.remove(vUserKeywords);
        return removed;
    }

    /**
     * Method removeUserKeywordsAt.
     * 
     * @param index
     * @return the element removed from the collection
     */
    public java.lang.String removeUserKeywordsAt(
            final int index) {
        java.lang.Object obj = this._userKeywordsList.remove(index);
        return (java.lang.String) obj;
    }

    /**
     * Sets the value of field 'description'.
     * 
     * @param description the value of field 'description'.
     */
    public void setDescription(
            final java.lang.String description) {
        this._description = description;
    }

    /**
     * 
     * 
     * @param index
     * @param vTag
     * @throws java.lang.IndexOutOfBoundsException if the index
     * given is outside the bounds of the collection
     */
    public void setTag(
            final int index,
            final Tag vTag)
            throws java.lang.IndexOutOfBoundsException {
        // check bounds for index
        if (index < 0 || index >= this._tagList.size()) {
            throw new IndexOutOfBoundsException("setTag: Index value '" + index + "' not in range [0.." + (this._tagList.size() - 1) + "]");
        }

        this._tagList.set(index, vTag);
    }


    /**
     * 
     * 
     * @param vTagArray
     */
    public void setTag(
            final Tag[] vTagArray) {
        //-- copy array
        _tagList.clear();

        for (int i = 0; i < vTagArray.length; i++) {
            this._tagList.add(vTagArray[i]);
        }
    }

    /**
     * 
     * 
     * @param index
     * @param vUserKeywords
     * @throws java.lang.IndexOutOfBoundsException if the index
     * given is outside the bounds of the collection
     */
    public void setUserKeywords(
            final int index,
            final java.lang.String vUserKeywords)
            throws java.lang.IndexOutOfBoundsException {
        // check bounds for index
        if (index < 0 || index >= this._userKeywordsList.size()) {
            throw new IndexOutOfBoundsException("setUserKeywords: Index value '" + index + "' not in range [0.." + (this._userKeywordsList.size() - 1) + "]");
        }

        this._userKeywordsList.set(index, vUserKeywords);
    }

    /**
     * 
     * 
     * @param vUserKeywordsArray
     */
    public void setUserKeywords(
            final java.lang.String[] vUserKeywordsArray) {
        //-- copy array
        _userKeywordsList.clear();

        for (int i = 0; i < vUserKeywordsArray.length; i++) {
            this._userKeywordsList.add(vUserKeywordsArray[i]);
        }
    }

    /**
     * Method unmarshal.
     * 
     * @param reader
     * @throws org.exolab.castor.xml.MarshalException if object is
     * null or if any SAXException is thrown during marshaling
     * @throws org.exolab.castor.xml.ValidationException if this
     * object is an invalid instance according to the schema
     * @return the unmarshaled TextDescription
     */
    public static TextDescription unmarshal(
            final java.io.Reader reader)
            throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
        return (TextDescription) Unmarshaller.unmarshal(TextDescription.class, reader);
    }

    /**
     * 
     * 
     * @throws org.exolab.castor.xml.ValidationException if this
     * object is an invalid instance according to the schema
     */
    public void validate()
            throws org.exolab.castor.xml.ValidationException {
        org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
        validator.validate(this);
    }
}
